code pieces for libpng handling