Patterning of masks by imaging