Revert "Revert use of 'with' statement for python 2.4"

This reverts commit 7fac4b8d4afb9830f9d9d16c5bde2b593896828c.