made ColorImageWriter more error robust