GCC 4.8 warning array subscript is above array bounds fixed.

There is explicit data type check in code bellow and it handles 1 and 3 channel images. I'll change condition on more accurate here.