As you can see, there are multiple entries for PNG format: ... '.png': 'PNG', '.apng': 'PNG' ....
Therefore, the result of _format_to_extension is unstable, because depends on order of items in the dict (ie. on order of serving them for for k, v in Image.EXTENSION.items() iteration).
Do not return 'apng' extension for 'PNG' format.
@vstoykov I've prepared the fix for this problem https://github.com/matthewwithanm/pilkit/pull/32#issuecomment-461177013: