Fix bugs in upscale script.