Fixed errors in PNG writing

Fixed errors in PNG writing, and added progress updates.