Fix where image component decoding takes place.

Fixes #2770, #2847

The image in the PDF had 4 bits per component and a color mask.  The mask wasn't working correctly because it was being applied to the rgb buffer that was already decoded whereas it should have been applied to the raw components before decoding.