Photons can have momentum, which, when doing relativity, blends together with energy into the momentum 4-vector [http://en.wikipedia.org/wiki/Four-momentum]. Relativity also asserts that energy and mass are related [http://en.wikipedia.org/wiki/Energy%E2%80%93momentum_relatio...], so you can imagine how we could talk about the "mass" of anything with energy or momentum.
Fun fact: One of the ways physicists are looking for Higgs is by looking for bumps in the "invariant mass" spectrum of LHC events with 2 photons!