Image formation in near-field optics