Fix an out of bounds crash in paint example.

The out of bounds error can occur when the window is resized and the
user tries to paint outside of the image.
Merge branch 'master' into out-of-bounds
Merge pull request #64 from TyOverby/out-of-bounds

Fix out of bounds error