Imaging the response of mesoscopic materials and devices to magnetic fields