BUG: MapIter leaked itself and arr and index objects

MapIterBind incorrectly behaved when failing, cleaning up most
but not everything. The callers have to decref the mapiter
object. Which basically means that MapIterBind does not even
have to decref the new fields (they are decrefed in the
mapiter dealloc anyway).

Note that trying to add tests checking the refcounting
failed, but the tests seem to fail at least in many cases
not because of the indexing.

Closes gh-3589
MAINT: Move NPY_BEGIN_THREADS_DEF to end of declarations.

The is an ';' at the end of the macro definition. When used and followed
by another ';', gcc thinks a statement has been made. An empty
statement, but still a statement. This causes compilation failure with
Python 3.4a.

The ';' should probably be removed, but that was undone in 1.7 to
maintain backward compatibility.
Merge pull request #3629 from charris/fix-out-of-order-declaration

MAINT: Move NPY_BEGIN_THREADS_DEF to end of declarations.
BUG: fix np.median so it accepts array_like input.  Clean up median tests.
Merge pull request #3628 from seberg/issue-3589

BUG: MapIter leaked itself and arr and index objects
Merge pull request #3630 from rgommers/fix-median

BUG: fix np.median so it accepts array_like input.  Clean up median test...
RF - allow ndarray.searchsorted to avoid making a copy for non-contiguous arrays
TST - add testing of searchsorted on unaligned arrays
BF - cast psorter pointer to intp
RF - have searchsorted copy haystack when the needle is bigger than the haystack
MAINT - update comments related to searchsorted to be consistent with code.
Merge pull request #3107 from MrBago/improve_searchsorted

Improve searchsorted
MAINT: Make setting mask values with scalars faster.

The current implementation assigns the mask value to a.flat, where a is
the mask being updated. In the scalar case, that is slower than
assigning to a[...], so when a is an instance of int, float, np.bool_,
or np.number use that instead.
Merge branch 'fast-mask'

* fast-mask:
  MAINT: Make setting mask values with scalars faster.