Theory of electromagnetic beams