Improved how outputs of PyFuncs are handled.

If the output can possibly be treated as scalars, then they are
converted to python floats. Otherwise, we make sure the output is an
ndarray with ndim == 1.