Separate input and output images in iconToGrayScale

When `img` has type `TYPE_BYTE_INDEXED`, `setColor` does not set desired pixel color. So it needs to create another image with correct type for output.