MRG: refactor for common Python 2/3 code

Changes necessary to run nibabel code in Python 2 and Python 3 without
running 2to3 at install time.  Also remove some fancy doctest markup
needed for Python < 2.6.