numpy 1.8 compatibility for NAN functions

Fixes the issue noted in #149 thanks to @astrofrog's solution to the SO question.