Auto-alignment of optical elements