Bugs fixed in PNG read and wriet func.