Fix image resampling bug when outside grid limits (#85)