Fix for  transparency = 0 in PNG mode P images

Includes #530. Adds test for the fix.  
Fixes #528.