Global variational methods in general relativity with applications to gravitational lensing