Created Function for reading and sampling 2D/3D image data

closes-#3544
In `DEBUG` mode, this code will throw unused variable warnings.  Can you add a call to 
```
libmesh_ignore(p);
```
in the `#else` branch to avoid this?  There are probably a few other places you'll have unused variable warnings too...