Image is converted to rgb and written