write RGB data properly and from more formats