Wavefront shaping to improve beam quality: converting a speckle pattern into a Gaussian spot