Theory for photon emission from a scanning tunneling microscope