Subtract mean from imagedata; fix off-by-one error.

Fixes #19.