Adaptive pupil masking for quasi-static speckle suppression