Overcoming loss of contrast in atom interferometry due to gravity gradients