   info = archive.getFileInfo filePath
   throw createNotFoundError(asarPath, filePath) unless info
 
+  if not options
+    options = encoding: null, flag: 'r'
+  else if util.isString options
+    options = encoding: options, flag: 'r'
+  else if not util.isObject options
+    throw new TypeError('Bad arguments')
+
+  flag = options.flag || 'r'
+  encoding = options.encoding
+
   buffer = new Buffer(info.size)
-  fd = fs.openSync archive.path, 'r'
+  fd = fs.openSync archive.path, flag
   fs.readSync fd, buffer, 0, info.size, info.offset
   fs.closeSync fd
-  buffer
+  if encoding then buffer.toString encoding else buffer

asar = process.atomBinding 'asar'
fs = require 'fs'
path = require 'path'

# Separate asar package's path from full path.
splitPath = (p) ->

  error

# Override fs APIs.
lstatSync = fs.lstatSync
fs.lstatSync = (p) ->
  [isAsar, asarPath, filePath] = splitPath p
  return lstatSync p unless isAsar

  archive = asar.createArchive asarPath
  throw new Error("Invalid package #{asarPath}") unless archive
