The Gauss linking integral on the 3-sphere and in hyperbolic 3-space