This shows the process you describe:

We drop the mass and it falls a distance $h$ picking up an energy $mgh$ as it falls. Then we convert the mass to a photon and send the photon back upwards. At the top we convert the photon back to a mass and repeat the cycle. The reason this doesn't violate conservation of energy is because of the gravitational redshift of the photon as we send it back upwards.
Light always moves at, well, the speed of light but that doesn't mean gravity has no effect on it. The energy of a photon is given by:
$$ E = h\nu $$
where $\nu$ is the photon frequency. As the photon moves upwards its energy decreases so its frequency $\nu$, decreases and this is the phenomenon known as the gravitational red shift. It turns out that the energy lost due to the gravitational red shift exactly balances out the energy gained by the mass as it falls, so as we go round the cycle the net energy change is zero and energy is conserved.
Let's go through this in detail: we start at the top with a mass $m$ so it has an equivalent energy $mc^2$. We let this fall a distance $h$ so its potential energy increases by $\Delta E = mgh$ so the total energy is $mc^2 + mgh$.
At the bottom we convert the mass to a photon and the photon frequency, $\nu_2$, is given by:
$$ h\nu_2 = mc^2 + mgh $$
Now we send the photon back upwards and as it moves up its frequency decreases to $\nu_1$ due to the gravitational red shift, so its energy decreases by $\Delta E = h\nu_2 - h\nu_1$.
At the top the photon frequency is $\nu_1$, so its energy is now $h\nu_1$, and we convert it back into a mass $M$ given by $hv_1 = Mc^2$. And what we find that the mass we end with, $M$, is exactly the same as the mass we started with, $m$, so the energy we ended with is exactly the same as the energy we started with.
You've probably spotted that I've just claimed the gravitational red shift exactly balances out the energy gained by the falling mass:
$$ h\nu_2 - h\nu_1 = mgh $$
We can prove this, but we're getting into the domain of general relativity so the working gets a bit involved.
Later: I've just realised the question is a duplicate, but I'll leave my answer here anyway in case it is of interest.