The random selection of phase mask parameters will cause the degradation of imaging quality, which can be fixed through the optimization process. We introduce an evaluation function based on the use of multitarget optimization to obtain optimal phase mask parameters. The proposed method gives the optimal phase mask parameters, which produce together an imaging quality at all defocus positions as best as possible. The cubic phase mask and the general cubic phase mask are both used to perform optimization with a proposed evaluation function. The simulation result gives quite interesting values for the two types of these phase masks.