Freeing and cleanup of malloc'd and PyMalloc'd memory in Jpeg Encode