The "rest mass" of a particle by definition is its mass as measured in its own frame of reference. For a photon, m = hf/c2, where h is Planck's constant and f is its frequency.
What's the frequency of a photon in its own frame of reference? In other words, how many wave peaks are passing you per second if you were travelling along side the photon? Zero, right? Therefore, the rest mass of the photon is also zero, theoretically.
Okay, someone who knows more physics than I do swat me down like a fly! :-)
BTW, here's a fun site that touches on lots of questions like that (e.g., see #126). My favorite is question #53: How much energy would be released if a marshmallow hit the Earth travelling 99.99% the speed of light (Answer: As much energy as in a "few dozen good-sized hydrogen bombs.").
I'm assuming you're combining E=hf and E=mc². The problem is that E=mc² doesn't apply to photons.
The general equation is E² = (pc)² + (mc²)² where p is the momentum. For a photon, E=pc; m=0 by geometry.
The problem with your analysis is that the principle of relativity prevents you from constructing--or even envisioning--a frame that is comoving with a photon. Light moves at speed c in all inertial frames; the moment you say that you are in an inertial frame, you are saying that light is moving at c with respect to you. Even in the limiting process where you approach the speed of light, the speed of light with respect to you does not go to zero. It remains fixed at c. Light itself does not have an inertial frame.