ENH: Added proper handling of nans for numpy.lib.function_base.median to closes issue #585