Updated scale function to work in raw pixel data
Improved average performance by raw pixel access