Fix segfault when the brush is out of the image.