Refactor the PngWriter.write{,_animated}_image() methods