Mass or no mass? Do all forms of energy have a mass? We know by $E=mc^2$ that mass and energy are directly proportional, but there are massless forms of energy such as electro-magnetic waves. I am also told that there are different forms of mass, such as invariant mass, virtual mass, and relativistic mass. This electro-magnetic wave seems to be a kind of quantum mechanical wave, that collapses into a particle dubbed a photon. When it interacts with matter, it gives that matter energy, which gives it more mass. Particles with an invariant mass also can be described by probabilistic waves, and behave in a similar way as photons. That is, when its wave function is disturbed in some way, it too collapses into a particle of some form, depending on what it is. The wave function must not be able to exceed the speed of light, because it has an invariant mass.
So my question is, what happens to the energy of an electromagnetic wave, when it transforms into an energy that has a form of mass, and where is that mass from, and what is the difference between the wave function of an invariant mass, verses the wave function of a photon without mass? Okay lots of question here, sorry.
 A: Mass, or more properly rest mass is simply a property of certain states of "stuff". Basically, if something - an isolated physical system - can be observed to be at rest relative to an inertial frame of reference, then it has rest mass and this Lorentz-invariant property measures the total energy of that system when observed from a relatively-at-rest inertial frame. I'm talking about, of course, the famous, but not general, equation $E = m\,c^2$. If your inertial frame is not at rest relative to that system, then the system's total energy $E$ is given by
$$E^2 = p^2\, c^2 + m^2\, c^4\tag{1}$$
where $p$ is the magnitude of the three-dimensional momentum vector for the system relative to your frame. The rest mass $m$ is unaffected by any Lorentz transformation.
Some systems have $m=0$, and these systems always have momentum relative to your inertial frame. Indeed, you will always observe their relative velocity to be precisely $c$. You can think of rest mass in two ways: it is acquired when system with rest mass of nought is confined in some way: if you put a photon in perfectly reflecting box so that is bounces back and forth, then the box-photon system now has an inertial mass that is $E/c^2$ greater than it was before. That is, if you shove the box initially at rest relative to you, you find that the impulse you need to make it move at a velocity $v\ll c$ relative to you is now  $E\,v/c^2$ greater than it was before, where $E$ is the photon's energy. The "mass" constant in Newton's second law has changed a little. Indeed, most (if not all - you'd have to get an answer from a field theorist) rest mass is acquired when a massless system such as a herd of photons, initially always running at $c$ is made to "stay put" in some way. See may answers here, here and method 2 in my answer here for more details.
So you can see that the property of rest mass is acquired by certain interactions and changes of state undergone by massless systems. Most generally, it is a coupling co-efficient that measures mutual tethering together of otherwise massless systems.
Another related way to think of rest mass is as a system's "stay-puttedness". Witness the dispersion relation for a massless particle like a photon: from Maxwell's equations we see that it is, in a vacuum, $\omega = k\,c$: the wavenumber is perfectly linearly dependent on the frequency so any signal or "wave group" we send with a massless field will propagate with a group velocity of precisely $c$: the shape of the wave is perfectly unchanged and we call such waves dispersionless.  Since (in 1D) a "bump" $\psi(z)$ propagates in time as $\psi(z\pm c\,t)$ with the same shape, this bump has zero "stay puttedness": it is always moving at speed $c$. Contrast this with the dispersion relationship for one electron which you can derive from the Klein-Gordon equation (which all particles fulfilling the Dirac equation must fulfill, although the converse is not true): we get 
$$\omega^2 = k^2 c^2 + \frac{m^2\,c^4}{\hbar^2}\tag{2}$$
which you can also derive from (1) with the de Broglie relationship $p = \hbar k$ and Planck relationship $E = \hbar\,\omega$. If we make $m$ bigger and bigger, we can get a group velocity $\mathrm{d}_k\,\omega$ as small as we please. The particle will still be subject to the Heisenberg uncertainty principle, but you can play around with wave-packets and show that the bigger the $m$, the more we can make even a small wavepacket (small $\delta\,x$, therefore big $\delta\,p$, by the HUP) behave like a classical, motionless point object. $m$ measures how readily a quantum system can be made to stay put.  
A: To answer your question let me start with the most basic constituents of the universe, i.e. elementary particles. 
Standard model of particle physics contains matter particles (quarks & leptons), force carriers (W/Z, photon, gluon) and the Higgs particle. Photon and gluon are massless, and the rest of the particles have non-zero masses. In a non-interacting situation, all those particles have their masses fixed, independent of their speed (So no relativistic mass which is an old way of thinking about relativistic kinematics anyways). 
When there are interactions between particles and enough energy to produce new particles (through $E=mc^2$), weird things happen. At this point we need quantum field theory to fully understand what's going on. Without going much into details, the way we think about the interactions is through force carrying particles I mentioned in the previous paragraph. When two particles interact, they can simply scatter off each other or the interaction can create a complete different set of particles. We understand the process of going from an "initial" set of particles to a "final" set of particles in terms of all the "paths" connecting them with the interactions allowed by the Standard Model. This situation is very similar to what happens in the double slit experiment. During this process virtual particles (from the above set I mentioned) are created. These intermediate particles have the exact same properties as the real ones, except their mass (or invariant mass) can be different than their actual mass. As in the double slit experiment, nature takes all the allowed paths between initial and final states.
At this point we can talk about the energy of our particles. According to special relativity there is a rest frame for any massive particle and in this special frame even though our particle is at rest it will have an energy given by $E_0 = mc^2$. So for a massless particle like photon there is no rest frame and hence no rest energy. But all the particles (massive or massless) have momentum, and a total energy given by $E = \sqrt{(mc^2)^2 + (pc)^2}$. Note that this reduces to $E = pc$ for a massless particle like photon.
If you think in terms quantum physics, an electromagnetic wave contains photons. So the energy of the electromagnetic wave comes from the energy of the photons i.e. the momentum carried by the photons (which is also related to their frequency or wavelength).
So far we talked about mass and energy of fundamental particles. What happens when we have bound states like protons/neutrons or nuclei or atoms or molecules? The mass of these compound objects depend on the bounding energy (or potential energy) that keeps them together. So for example the mass of a proton is not equal to the total mass of the quarks that makes up the proton (two up, one down quark) but is mostly created by the interaction between these quarks explained by quantum chromodynamics (QCD). Since there is more than one fundamental particle making up our bound states, there can also be excited states with slightly different masses. An atom for example can absorb a photon and switch to an excited state for a very brief time which has a different mass. This mass difference is usually very small. This only happens when the energy of the photon matches the difference between the discrete energy levels of the atom. Most of the time they will only scatter like billiard balls. 
For an even larger bound system like a solid object, an absorbed electromagnetic wave usually changes the temperature of the object. In this larger system, we can think of atoms organized in a geometric pattern. On the average they sit at fixed points on a 3D lattice but they all individually vibrate around their equilibrium points. So an electromagnetic wave absorbed by the object usually changes the amplitude of these vibrations or the average vibration energy i.e. the temperature of the object.
A: This answer is complementary to the others. In the following photo is a  positron annihilation on an electron going to two photons, one of them interacting in the liquid of the bubble chamber.
 
We know the direction of the curves of electrons from a single compton close to the fiducial mark in the middle of the picture. So the drawing for clarity, shows a positron annihilating on an electron in an atom of the liquid. There is a small undisturbed  space, indicated by the yellow line and then an electron positron pair appears . The photon gave up its energy to create this pair in the field of a nucleus of the atoms in the liquid.
The yellow line is the photon from the one of the two photons  that the e+e- annihilation goes to, the other photon does not interact. ( the smaller interaction on the right is irrelevant to the first. If interested read up at the link provided)
So, if enough energy is available, pair production of elementary particles results from photon interactions with fields, the energy of the photon turning into the energy carried by two massive particles.
Please note that this is a very rare "photo" of a photon :) , like the Cheshire cat's smile.
