Generation of high-purity structured light beams is challenging due to transverse phase aberrations in the optical setup consisting of components such as spatial light modulators (SLMs), lenses, and mirrors. Several phase compensation approaches have been explored in previous work, of which the Gerchberg–Saxton(GS) phase retrieval algorithm has been quite popular. In this paper, we have proposed and experimentally demonstrated a modified GS algorithm based on aperture optimization for phase compensation and compared its performance for a wide range of topological charges using inline, pre-, and post-phase compensation techniques. We find that the post-compensation configuration provides the best performance, and by employing such phase compensation we can achieve a 35% enhancement in modal purity of the generated orbital angular momentum (OAM) beam while reducing the nearest neighbor cross-talk by 9.37 dB.