Allopen in context

Refactor allopen function to provide context managers and a little bit of common interface between the various files that can be opened.