An apparatus and method for ultrafast real-time optical imaging that can be used for imaging dynamic events such as microfluidics or laser surgery is provided. The apparatus and methods encode spatial information from a sample into a back reflection of a two-dimensional spectral brush that is generated with a two-dimensional disperser and a light source that is mapped in to the time domain with a temporal disperser. The temporal waveform is preferably captured by an optical detector, converted to an electrical signal that is digitized and processed to provide two dimensional and three dimensional images. The produced signals can be optically or electronically amplified. Detection may be improved with correlation matching against a database in the time domain or the spatial domain. Embodiments for endoscopy, microscopy and simultaneous imaging and laser ablation with a single fiber are illustrated.