diff --git a/patoolib/__init__.py b/patoolib/__init__.py
index 3879ecf..9b9a02a 100644
--- a/patoolib/__init__.py
+++ b/patoolib/__init__.py
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 import os
 import shutil
-from . import util
+from patoolib import util
 
 # Supported archive commands
 ArchiveCommands = ('list', 'extract', 'test', 'create')
diff --git a/patoolib/programs/bzip2.py b/patoolib/programs/bzip2.py
index f45b75b..5d5a8cf 100644
--- a/patoolib/programs/bzip2.py
+++ b/patoolib/programs/bzip2.py
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the bzip2 program."""
-from .. import util
+from patoolib import util
 
 
 def extract_bzip2 (archive, encoding, cmd, **kwargs):
diff --git a/patoolib/programs/compress.py b/patoolib/programs/compress.py
index e4bd9ca..db4f0c7 100644
--- a/patoolib/programs/compress.py
+++ b/patoolib/programs/compress.py
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the uncompress.real program."""
-from .. import util
+from patoolib import util
 
 
 def create_compress (archive, encoding, cmd, *args, **kwargs):
diff --git a/patoolib/programs/cpio.py b/patoolib/programs/cpio.py
index c2850ac..bd36bbc 100644
--- a/patoolib/programs/cpio.py
+++ b/patoolib/programs/cpio.py
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the cpio program."""
-from .. import util
+from patoolib import util
 
 def extract_cpio (archive, encoding, cmd, **kwargs):
     """Extract a CPIO archive."""
diff --git a/patoolib/programs/echo.py b/patoolib/programs/echo.py
index 9b0dea8..dab8e25 100644
--- a/patoolib/programs/echo.py
+++ b/patoolib/programs/echo.py
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the echo program."""
-from .. import util
+from patoolib import util
 
 
 def list_bzip2 (archive, encoding, cmd, **kwargs):
diff --git a/patoolib/programs/gzip.py b/patoolib/programs/gzip.py
index 44772a4..054e1c4 100644
--- a/patoolib/programs/gzip.py
+++ b/patoolib/programs/gzip.py
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the gzip program."""
-from .. import util
+from patoolib import util
 
 
 def extract_gzip (archive, encoding, cmd, **kwargs):
diff --git a/patoolib/programs/lzma.py b/patoolib/programs/lzma.py
index 961d52b..f50fb65 100644
--- a/patoolib/programs/lzma.py
+++ b/patoolib/programs/lzma.py
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the lzma program."""
-from .. import util
+from patoolib import util
 
 
 def extract_lzma (archive, encoding, cmd, **kwargs):
diff --git a/patoolib/programs/lzop.py b/patoolib/programs/lzop.py
index 36759c8..7128404 100644
--- a/patoolib/programs/lzop.py
+++ b/patoolib/programs/lzop.py
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the lzop program."""
-from .. import util
+from patoolib import util
 
 
 def extract_lzop (archive, encoding, cmd, **kwargs):
diff --git a/patoolib/programs/pbzip2.py b/patoolib/programs/pbzip2.py
index 43cf57e..876f95d 100644
--- a/patoolib/programs/pbzip2.py
+++ b/patoolib/programs/pbzip2.py
@@ -15,4 +15,4 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the pbzip2 program."""
 # bzip2 and pbzip2 are compatible
-from .bzip2 import extract_bzip2, test_bzip2, create_bzip2
+from patoolib.programs.bzip2 import extract_bzip2, test_bzip2, create_bzip2
diff --git a/patoolib/programs/rpm2cpio.py b/patoolib/programs/rpm2cpio.py
index b241bea..d6273d6 100644
--- a/patoolib/programs/rpm2cpio.py
+++ b/patoolib/programs/rpm2cpio.py
@@ -15,7 +15,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the rpm2cpio program."""
 import os
-from .. import util
+from patoolib import util
 
 def extract_rpm (archive, encoding, cmd, **kwargs):
     """Extract a DEB archive."""
diff --git a/patoolib/programs/uncompress.py b/patoolib/programs/uncompress.py
index 535b7bf..9d85cc8 100644
--- a/patoolib/programs/uncompress.py
+++ b/patoolib/programs/uncompress.py
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the uncompress.real program."""
-from .. import util
+from patoolib import util
 
 
 def extract_compress (archive, encoding, cmd, **kwargs):
diff --git a/patoolib/programs/xz.py b/patoolib/programs/xz.py
index 0223251..010cd91 100644
--- a/patoolib/programs/xz.py
+++ b/patoolib/programs/xz.py
@@ -14,7 +14,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Archive commands for the xz program."""
-from .. import util
+from patoolib import util
 
 
 def extract_xz (archive, encoding, cmd, **kwargs):
diff --git a/patoolib/util.py b/patoolib/util.py
index a9d5500..e4b6062 100644
--- a/patoolib/util.py
+++ b/patoolib/util.py
@@ -14,7 +14,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """Utility functions."""
-from __future__ import with_statement
 import os
 import sys
 import subprocess
@@ -277,8 +276,11 @@ def get_nt_7z_dir ():
     """Return 7-Zip directory from registry, or an empty string."""
     try:
         import _winreg
-        with _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\7-Zip") as key:
+        key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\7-Zip")
+        try:
             return _winreg.QueryValueEx(key, "Path")[0]
+        finally:
+            _winreg.CloseKey(key)
     except WindowsError:
         return ""