Optimization of quantum Monte Carlo wave functions by energy minimization