diff --git a/src/Util.cpp b/src/Util.cpp
index 9e3b7d9..6ab1614 100644
--- a/src/Util.cpp
+++ b/src/Util.cpp
@@ -86,8 +86,12 @@ bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
     fclose(fp);
     return false;
   }
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
 
+#else
   if(setjmp(png_ptr->jmpbuf)) {
+#endif
+  if(setjmp(png_jmpbuf(png_ptr))) {
     png_destroy_write_struct(&png_ptr,NULL);
     fclose(fp);
     return false;
@@ -992,7 +996,7 @@ void utilWriteData(gzFile gzFile, variable_desc *data)
 
 gzFile utilGzOpen(const char *file, const char *mode)
 {
-  utilGzWriteFunc = (int (ZEXPORT *)(void *,void * const, unsigned int))gzwrite;
+  utilGzWriteFunc = (int (ZEXPORT *)(gzFile,const voidp, unsigned int))gzwrite;
   utilGzReadFunc = gzread;
   utilGzCloseFunc = gzclose;
 
