Nullpointer protection on image grabbing.