Added an image scaling function