Improved some efficiency and exception handling in the image processing, hopefully this fixes the apng issue.