Improve opening of file/url
Set __package__ if not set