Optical and x-ray imaging of electron beams using synchrotron emission