Systems and techniques for an optical scanning microscope and/or other appropriate imaging system includes components for scanning and collecting focused images of a tissue sample and/or other object disposed on a slide. The focusing system described herein provides for determining best focus for each snapshot as a snapshot is captured, which may be referred to as “on-the-fly focusing.” Best focus may be determined using an error function generated according to movement of a dither focusing lens. The devices and techniques provided herein lead to significant reductions in the time required for forming a digital image of an area in a pathology slide and provide for the creation of high quality digital images of a specimen at high throughput.