Fixed bug in toRGB