Fix incompatibilities with numpy 1.5.x.  Closes gh-2677.