Fixed a bug in image scaling