added support for grayscale images