Correct whitespace in savepng.c
Remove stupid memleaks.
Add one more error check.
Workaround SDL2 bugs.