png read fixes

- call png_read_end()
- catch errors during header read
- free read mem sooner