There are several conceptual confusions here. Mass is irrelevant. This is purely a kinematical question, it does not depend on dynamics at all: so suppose the Universe is completely empty---no mass or energy, completely flat Minkowski space. For simplicity, suppose there is one spatial dimenion, $x$, and one time dimension, and the velocity of light is unity, and $ds = dx^2 - dt^2.$ If one co-ordinate system has its origin moving at the speed of light with respect to the origin of another co-ordinate system, one of them must fail to be an inertial reference frame. They cannot be connected by a Lorentz transformation. This is a kinematical theorem which does not depend on what dynamical law of motion Nature employs: it only depends on the principle of relativity. (It is true in General Relativity also, but has no importance there because in GR we do not care about whether a co-ordinate system is inertial or not.) So we cannot use a Lorentz transformation to compare what is seen by an observer travelling along with a photon with whast is seen by another observer for whom that origin is moving at the speed of light.
But the O.P. is getting at something, it just needs to be slightly rephrased: two observers in relative motion to each other, each using an inertial frame, will see the shape of a photon differently---there will be a contraction or expansion---this is the Doppler effect. No one really knows what the shape of the photon is, but let us suppose that it has no mass and is perfectly spherical to observer 1 in the x,t reference frame (a sphere in one dimension is an interval) with unit diameter. I.e., suppose one edge of the photon is at (0,0) and the other edge at (1,0) in the x,t reference frame. If anyone wants to criticise the O.P. and naive ideas of spherical massless photons, just think of two points in space-time which are moving at the speed of light. There are no rigid bodies in the real world either, so we need not imagine anything in between.
For the sake of generality, though, we need not assume these two points are travelling at the speed of light: assume only that they are travelling at the same velocity $w$, i.e., at the same speed $|w|$ and in the same direction, so that for observer 1 they are always the same spatial distance apart.
This means that we are considering two world-lines: the world-line of (0,0) (point one) is $$x_1 = wt_1$$ and the world-line of the other point, which started at (1,0), is $$x_2 = wt_2 + 1.$$
Consider another reference frame x',t' travelling at velocity $v$ relative to the first one, so that the co-ordinates are connected by the usual Lorentz transformation, $$ x' = {x-vt\over\sqrt{1-v^2}}$$
$$ t' = {t-xv\over\sqrt{1-v^2}}.$$
The first world-line becomes $$ x'_1 = {wt_1-vt_1\over\sqrt{1-v^2}}$$ $$ t'_1 = {t_1-vwt_1\over\sqrt{1-v^2}}$$ where $t_1$ is merely a parameter. On eliminating this parameter, be obtain $$x_1' = {w-v\over 1-vw}t_1',$$ i.e., the apparent velocity has suffered a shift, which is not the Lorentz contraction at all. Of course. Unless $w=1$, in which case there has been no change (the speed of light is invariant under a Lorentz transformation).
But the O.P. asks about the change in the spatial separation between the two world-lines.
The second world-line is $$x'_2 = {wt_2+1-vt_2\over\sqrt{1-v^2}}$$ $$t'_2 = {t_2-v(wt_2+1)\over\sqrt{1-v^2}},$$ which will have the same slope but a different intercept: eliminating $t_2$ we proceed as follows. $$x'_2 = {t_2(w-v)\over\sqrt{1-v^2}} + {1\over\sqrt{1-v^2}}$$ $$t'_2 = {t_2(1-vw)\over\sqrt{1-v^2}} -{v\over\sqrt{1-v^2}},$$ and so $$x'_2 = {w-v\over 1-vw} t'_2 + {v{w-v\over 1-vw}\over\sqrt{1-v^2}} + {1\over\sqrt{1-v^2}}.$$
The second reference frame sees, at $t'_2 = 0$, the first point at (0,0) but the second point at $((v{w-v\over1-vw}+1)/\sqrt{1-v^2},0)$. Simplifying, since $v{w-v\over 1-vw} + 1 = {vw-w^2\over1-vw} + {1-vw\over1-vw} = {1-v^2\over 1-vw}$, and now dividing by $\sqrt{1-v^2}$, we obtain a simpler expression for point 2 at this time, $$ ({\sqrt{1-v^2}\over1-vw}, 0 ).$$ This is not the Lorentz contraction, it is the Doppler effect. If $w=0$, the case considered by the Lorentz contraction, we do get the Lorentz contraction as a special case of the Doppler effect: a separation in space of $\sqrt{1-v^2}$ between the two world lines in the second reference frame, instead of unit separation in space as seen by the first reference frame in which the points are motionless.
But suppose $w=1$, as is the case with a photon. We then get a separation in space of $${\sqrt{1-v^2}\over1-v} = \sqrt{1+v\over1-v}.$$ Sometimes this is a contraction of the spherical photon, other times, an expansion. In reality, of course, it is impractical to observe the two diametrically opposite ends of a photon...so the practical application of this formula is for two wave crests of a wave travelling at the speed of light or the speed of sound. The apparent wavelength will expand or contract. But in theory, if the photon were a massless particle with a spherical shape in reference frame 1, it would have some other shape in reference frame 2. And by letting $v\rightarrow \pm 1$, one can see the contraction approach zero, and the expansion approach infinity.