ColorsToBytes function (confirmed working)