Better handling of NaN in ImageGrid.

Correctly falls back to the border color.