corrected GrayImage to canvas array function