Rebase ipython_directive on top of recent ipython updated version
https://github.com/ipython/ipython/pull/4570

We'd prefer to get rid of the duplication, but we have some tweaks in place
which ipython does not.

I rebased everythingon top of ipython to generae a clean diff, if they pick it up
we can make the transition, otherwise we synched for now.

cc @takluyver, if you're interested, check the diff between     2e3c608 and     82b8c3a
for an unobstructed view.

@jorisvandenbossche, can you check this out and let me know if I missed anything?
I included the cython magic fixes you pointed out.

related https://github.com/pydata/pandas/issues/5221
