Fix a bug with grayscale image