1. A computer-implemented method for optimizing a mask pattern and an illumination source, the method comprising: identifying a plurality of source points of an illumination source and a predetermined mask pattern; selecting evaluation points in an image plane of an image formed by illumination provided to the predetermined mask pattern by the illumination source; determining an image log slope (ILS) of illumination at each evaluation point; determining the Hessian of the image log slope, wherein the Hessian comprises a second order partial derivative with respect to two different variables associated with the mask pattern and the illumination source; and using the Hessian for determining at least one of an improved mask pattern and an improved illumination source which maximizes the image log slope at the selected evaluation points, wherein at least some of the above functions are performed by a computer.