Add writeandexecute magic

This magic can be used to write the content of a cell to a .py
file and afterwards execute the cell. This can be used as a
replacement for the --script parameter to the notebook server.

Code is replaced on the next execution (using the needed identifier)
and other code can be appended by using the same file name.

Example:
```
%%writeandexecute -i <identifier> <filename>
print "Hello world"
```

This would write the `print "Hello World"` with the some surrounding
comments to the file "filename.py".

Cell content is transformed, so %%magic commands executeable, but
only in an ipython environment, as it depends on a working
`get_ipython()`.

This is fixes ipython/ipython#3295