There is a growing effort to image single neurons in vivo, and observe their individual contribution to the brain's functional organization. This effort generally relies on two-photon imaging to explore the structure and activity of cortical columns extending beneath the brain's surface. The need to protect living tissue, however, demands the introduction of coverslips and similar objects that can modify the optics of the imaging beam. This paper develops three-dimensional (3D) analytical and numerical models to characterize and correct for the resulting degradation of image quality. We have illustrated the use of these models by describing a simple, practical technique to reduce the effect of spherical aberration for in vivo two-photon fluorescence experiments.