Fix memory leaks

Fix two memory leaks in the xfer/xfer2 functions.
If an error occurs we need to free up the transfer buffers.
We are modifying and returning the list we are passed.  This is against normal Python policy: functions should either return a new value, or modify an argument in place (not return a modified argument). A related issue is that PyList_SET_ITEM does not dereference the object that was in the list, so we are potentially leaking all the items passed in.
These are fixed by allocating and populating a new list object.