Optimizations for 1 bpc images

Two low-level optimizations for black and white images and image masks.

1. in getComponents(), unroll a loop to save some if's
2. in fillGrayBuffer(), join buffer decoding and scaling into one single loop, and apply simplifications for the 1bpc special case

FF nightly rendering times for #2790 are reduced by ~10-20%:
Windows: 3750ms --> 3000ms
Linux: 3800ms --> 3400ms
Chrome 35, Linux: 5500ms --> 4700ms