Pass the ownership of the map object

Shouldn't try to free the wrapper yet though as layers are still owned by
it. The wrappers might leak memory when Tiled is quit, should look into
that, but anyway, it's not script writer's responsibility to manage
references.