Photons have mass when traveling in speed of light (what they always do), but they don't have a rest mass. If they had one, they indeed would become infintely heavy, but they haven't wink