diff -ru h5utils-1.12.1.orig/writepng.c h5utils-1.12.1/writepng.c
--- h5utils-1.12.1.orig/writepng.c	2009-06-12 22:58:50.000000000 +0200
+++ h5utils-1.12.1/writepng.c	2012-08-27 15:17:33.843205314 +0200
@@ -240,6 +240,7 @@
      double skewsin = sin(skew), skewcos = cos(skew);
      REAL minoverlay = 0, maxoverlay = 0;
      png_byte mask_byte;
+     png_colorp palette;
 
      /* we must use direct color for translucent overlays */
      if (overlay)
@@ -309,7 +310,11 @@
      }
      /* Set error handling.  REQUIRED if you aren't supplying your own *
       * error hadnling functions in the png_create_write_struct() call. */
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+     if (setjmp(png_jmpbuf(png_ptr))) {
+#else
      if (setjmp(png_ptr->jmpbuf)) {
+#endif
 	  /* If we get here, we had a problem reading the file */
 	  fclose(fp);
 	  png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
@@ -334,7 +339,6 @@
 		       PNG_INTERLACE_NONE,
 		       PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
      else {
-	  png_colorp palette;
 
 	  png_set_IHDR(png_ptr, info_ptr, width, height, 8 /* bit_depth */ ,
 		       PNG_COLOR_TYPE_PALETTE,
@@ -434,8 +438,14 @@
      png_write_end(png_ptr, info_ptr);
 
      /* if you malloced the palette, free it here */
+#if PNG_LIBPNG_VER_MAJOR >= 1 && PNG_LIBPNG_VER_MINOR >= 4
+     if (eight_bit) {
+          png_free(png_ptr, palette);
+     }
+	palette = NULL;
+#else
      free(info_ptr->palette);
-
+#endif
      /* if you allocated any text comments, free them here */
 
      /* clean up after the write, and free any memory allocated */
