undistort edges handling

Added some conditions to the interpolation in the undistort function to
handle the edge pixles