MAINT: Use np.errstate context manager.

Now that Python < 2.6 is no longer supported we can use the errstate
context manager in places where constructs like
```
    old = seterr(invalid='ignore')
    try:
        blah
    finally:
       seterr(**old)
```
were used.
Merge pull request #3518 from charris/use-errstate-context-manager

MAINT: Use np.errstate context manager.