Better handling of `__file__` when running scripts.

This pull request should address the issues raised in #1814:

* Set `__file__` when running `ipython filename.ipy`
* Avoid leaking `__file__` back into the main namespace when using `%run` or when running a script interactively (`ipython -i`).