Add python implementation of image rescaling