High-energy photons from expanding quark-gluon plasma and hot hadronic matter