added function to convert from indexed or rgb to grey scale