The transverse intensity distribution of a beam emerging from a linear accelerator can be described well by a two-dimensional Gaussian function with elliptical contours. A method is presented that utilizes third-order optics to modify this Gaussian beam distribution and to produce at a given location along the beam direction a more uniform beam, which also is confined within a prescribed rectangular area.