Pre-calculate start offset, optimize bound check

Increased performance by 30% for RGBA and 45% for Gray images, minor
performance increase for 16-bit images.

The start offset calculated by createWeights are stored in a slice and
passed to the resize functions to prevent duplication of effort.
Optimized Nearest-Neighbor function - 2x faster
Merge branch 'refactor'