Fix underflow bug in image subtracting method