Scale images to fit without memory problems