emulate 'with' context manager
to prevent resource leak on error

Signed-off-by: Arvind Chembarpu <achembarpu@gmail.com>
readded python3 specifiers
added python2.6 as well

Signed-off-by: Arvind Chembarpu <achembarpu@gmail.com>