We propose a novel method for the fast synthesis of low complexity model-based optical proximity correction (OPC) and phase shift masks (PSM) to improve the resolution and pattern fidelity of optical microlithography. We use the pixel-based mask representation, a continuous function formulation, and gradient based iterative optimization techniques to solve the above inverse problem. The continuous function formulation allows analytic calculation of the gradient. Pixel-based parametrization provides tremendous liberty in terms of the features possible in the synthesized masks, but also suffers the inherent disadvantage that the masks are very complex and difficult to manufacture. We therefore introduce the regularization framework; a useful tool which provides the flexibility to promote certain desirable properties in the solution. We employ the above framework to ensure that the estimated masks have only two or three (allowable) transmission values and are also comparatively simple and easy to manufacture. The results demonstrate that we are able to bring the CD on target using OPC masks. Furthermore, we were also able to boost the contrast of the aerial image using attenuated, strong, and 100% transmission phase shift masks. Our algorithm automatically (and optimally) adds assist-bars, dog-ears, serifs, anti-serifs, and other custom structures best suited for printing the desired pattern.