Optimization of conversion efficiency and spatial quality of high-order harmonic generation