SED from Cube code

Made a pull request while I work on this in case you have comments.
Add tests for the default `None` cases for the limits also.
You can use this command to make sure every line in your function is tested:
```
python setup.py test -V --coverage -t gammapy/image/tests/test_utils.py
```