In this paper, we develop an image-gradient-based algorithm to simultaneously optimize various cost functions for inverse mask design. The algorithm employs an iterative approach which evaluates the gradient decent of the resist image, aerial image, and the aerial image contrast with a pre-assigned step length. Moreover, an independent iteration step is inserted among iterations for binary mask conversion. We show that the proposed algorithm allows fast convergence while achieving high aerial image contrast. The impacts of each cost function on the pattern fidelity and convergence are also discussed.