Generation of a flat-top laser beam for gravitational wave detectors by means of a nonspherical Fabry-Perot resonator