The extension of the master stability function (MSF) to analyze stability of generalized synchronization for coupled nearly identical oscillators is discussed. The nearly identical nature of the coupled oscillators comes from some parameter mismatch while the dynamical equations are the same for all the oscillators. From the stability criteria of the MSF, we construct optimal networks with better synchronization property, i. e. the synchronization is stable for widest possible range of coupling parameter. In the optimized networks the nodes with parameter value at one extreme are selected as hubs. The pair of nodes with larger parameter difference are preferred to create links in the optimized networks. And the optimized networks are found to be disassortative in nature, i. e. the nodes with high degree tend to connect with nodes with low degree.