Fixes to the scale function so that edges are handled by extending the edges