Fix input/output arrays with new numpy.i swig typemaps

- Apply extra numpy typemaps where the size is not const.

- With the new numpy API we can no longer modify the data pointer for an
  array but this is ok, by setting the size to zero numpy will not try
  to access data that it shouldn't.

This still feels a bit hacky, it might be better to eventually switch to using `del` in Python or just letting the variable go out of scope, then have numpy call the data restore routine, rather than calling data restore directly.