If photon is near an atomic nucleus, the energy of a photon can be converted into an electron and a positron. The photon's energy is converted into a particle's mass through the Einstein's Equation. In particle physics, there is a phenomenon called pair production where energy is in fact transformed into matter.