Use Magick::Image::write rather than a hand-made loop; much faster.