fixed bug at grayscale conversion