Electromagnetic theory of Talbot imaging