Revert use of 'with' statement for python 2.4

this commit should be reversed when 2.4 support is dropped