python-imaging/Pillow — pull request #180 by d-schmidt (2013-04-09 11:31:01+00:00)
Title: create a palette before converting transparent L-mode to RGBA

fixes #154

If you load a L-mode image with transparency and want to save it as L or P-mode image you can maintain the transparency by adding it to the save() method as parameter.
This this doesn't work if you convert said image to RGBA and try to save it as PNG.

Converting to RGBA only includes alphas set in a palette so we have to create a palette and add alphas even for an greyscale image. Another solution would be rewriting the color conversion parts to accept and use a transparency value.