modified code to work with chrome and also removed the getImageData(), now working with layers