Exports the PNG API out of the main.c file
Puts stuff on heap instead of stack
Cleans up the memory leaks.