There actually is a law of conservation of mass (it's the same law, because mass is energy) and it only appears violated if you forget about the particles that are zooming away at the speed of light. Of course the mass of a system changes if mass can flow in and out.
When you put a photon in a stationary box, the "relativistic mass" of the photon becomes part of the "rest mass" of the photon-box system. You can't ignore it.