diff --git a/buildwrapper.cabal b/buildwrapper.cabal
--- a/buildwrapper.cabal
+++ b/buildwrapper.cabal
@@ -1,5 +1,5 @@
 name:           buildwrapper
-version:        0.9.0
+version:        0.9.1
 cabal-version:  >= 1.8
 build-type:     Custom
 license:        BSD3
diff --git a/src/Language/Haskell/BuildWrapper/API.hs b/src/Language/Haskell/BuildWrapper/API.hs
--- a/src/Language/Haskell/BuildWrapper/API.hs
+++ b/src/Language/Haskell/BuildWrapper/API.hs
@@ -26,9 +26,6 @@
 import Prelude hiding (readFile, writeFile)
 import qualified Data.Vector as V
 
---import System.IO.UTF8 hiding (readFile, writeFile)
---import Codec.Binary.UTF8.String
-
 import Control.Monad.State
 import Language.Haskell.Exts.Annotated hiding (String)
 import Language.Preprocessor.Cpphs
diff --git a/src/Language/Haskell/BuildWrapper/Base.hs b/src/Language/Haskell/BuildWrapper/Base.hs
--- a/src/Language/Haskell/BuildWrapper/Base.hs
+++ b/src/Language/Haskell/BuildWrapper/Base.hs
@@ -35,9 +35,8 @@
 import Data.List (isPrefixOf)
 import Data.Maybe (catMaybes)
 
-import System.IO.UTF8 (hPutStr,hGetContents)
 import           Data.ByteString.UTF8     (toString)
-import System.IO (IOMode, openBinaryFile, IOMode(..), Handle, hClose, hFlush, stdout)
+import System.IO (IOMode, openBinaryFile, IOMode(..), Handle, hClose, hFlush, stdout, hPutStr, hGetContents, hSetEncoding, utf8)
 import Control.DeepSeq (rnf, NFData)
 
 -- | State type
@@ -801,13 +800,14 @@
 -- readFile n=hGetContents =<< openBinaryFile n ReadMode
 readFile n =  do
         inFile<- openBinaryFile n ReadMode
+        hSetEncoding inFile utf8
         contents <- hGetContents inFile
         rnf contents `seq` hClose inFile -- force the whole file to be read, then close http://stackoverflow.com/a/297630/827593
         return contents
 
 -- | write string to file
 writeFile :: FilePath -> String -> IO ()
-writeFile n s = withBinaryFile n WriteMode (`hPutStr` s)      
+writeFile n s = withBinaryFile n WriteMode (\h -> hSetEncoding h utf8 >> h `hPutStr` s)      
 
 -- | perform operation on a binary opened file
 withBinaryFile :: FilePath -> IOMode -> (Handle -> IO a) -> IO a
diff --git a/src/Language/Haskell/BuildWrapper/Cabal.hs b/src/Language/Haskell/BuildWrapper/Cabal.hs
--- a/src/Language/Haskell/BuildWrapper/Cabal.hs
+++ b/src/Language/Haskell/BuildWrapper/Cabal.hs
@@ -544,7 +544,10 @@
 fileGhcOptions (CabalBuildInfo tgt _ isLib _ _)=do
         dist_dir<-getDistDir
         let inplace=dist_dir </> "package.conf.inplace"
-        inplaceExist<-liftIO $ doesFileExist inplace
+        inplaceExist<-liftIO $ do
+          f<-doesFileExist inplace
+          d<-doesDirectoryExist inplace -- in Cabal 1.22
+          return $ f || d
         n<-getPackageName
         let pkg
                   | isLib =
