Decoding of information in the brain requires the imaging of large neuronal networks using e.g. two-photon microscopy (TPM). Fast control of the focus in 3D can be achieved with phase shaping of the light beam using acousto-optic deflectors (AODs). However, beam shaping using AODs is not straightforward because of non-stationary of acousto-optic diffraction. Here, we demonstrated a new stable AOD-based phase modulator, which operates at a rate of up to about hundred kHz. It provides opportunity for 3D scanning in TPM with the possibility to correct aberrations independently for every focus position or to achieve refocusing of scattered photons in rapidly decorrelating tissues.