Revert "bugfix for "cannot write mode P as JPEG""

This reverts commit 8073f1821b37bf314c72d57afb38b72fb89bf94a.