The design of a desired optical transfer function (OTF) is a common problem that has many possible applications. A well-known application for OTF design is beam shaping for incoherent illumination. However, other applications such as optical signal processing can also be addressed with this system. We design and realize an optimal phase only filter that, when attached to the imaging lens, enables an optimization (based on the minimal mean square error criterion) to a desired OTF. By combining several OTF design goal requirements, each represents a different plane along the beam propagation direction, an imaging system with an increased depth of focus is obtained. Because a phase only filter is used, high energetic efficiency is achieved.