Adjoint optimization of free-space metasurfaces