diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index cdc5907c508b733c52ed4013754c167cc383693e..d39b692adc8dc127f4c503a4ec77f405862080a7 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -174,7 +174,7 @@ class Pathname
     # Get enough of the file to detect common file types
     # POSIX tar magic has a 257 byte offset
     # magic numbers stolen from /usr/share/file/magic/
-    case open { |f| f.read(262) }
+    case open('rb') { |f| f.read(262) }
     when /^PK\003\004/n         then :zip
     when /^\037\213/n           then :gzip
     when /^BZh/n                then :bzip2
@@ -200,7 +200,7 @@ class Pathname
   def incremental_hash(hasher)
     incr_hash = hasher.new
     buf = ""
-    open('r') { |f| incr_hash << buf while f.read(1024, buf) }
+    open('rb') { |f| incr_hash << buf while f.read(1024, buf) }
     incr_hash.hexdigest
   end