Fixed unintended modification of input image

The tests were failing because of an actual bug in the code.  The image that was passed in (by reference) was not copied before being modified.

The tests now pass.