Fixed upload of images. Also implemented scaling.