Better handling of `__file__` when running scripts.

* Set `__file__` when running `ipython filename.ipy`
* Avoid leaking `__file__` back into the main namespace when using `%run`.
Add test for `__file__` behavior in `%run`.
Add test for `__file__` behavior in `ipython <file>`
cast unicode in oinspect.find_file
fix %edit foo for interactively defined variables

Effectively handles cases such as:

    In [1]: def foo(): return 5
    In [2]: %edit foo

Where `%edit foo` effectively turns into `%edit 1` by parsing the `<ipython-input-NN-…>` fake filename.
Add duplicated entry in test_history
Add unique boolean argument to history search
Add a test for history search with unique=True
Add a test for combination of n/unique arguments
Add -u argument to %history magic
Use start=1 for enumerate rather than doing i+1
Fix units / res args for *png* plotting device.

Update the `units` argument so that it accepts values from ["px", "in",
"cm", "mm"].

The `res` argument was added for the cases where `units` is specified
and is not default (px). A default value of 72 is provided by rmagic in
the case that `units` is not "px" but `res` is not specified.
More informative name error
Merge pull request #2737 from rmcgibbo/rmagic_informative_error

Rmagic: error message when moving an non-existant variable from python to R
Encode output that is sent to the pager.
Following #2737 this error is now a name error
Add note to `%cython` Black-Scholes example warning of missing erf.
Merge pull request #2740 from jenshnielsen/rnameerror

Fix tests for rmagic (KeyError -> NameError).

Caused by #2737.
Address comments in the PR.
BUG: Octavemagic inline plots not working on Windows: Fixed