def read(self, filename, binary_mode=False, size=None, offset=None):
        """Reads contents of a file to a string.

        Args:
            filename: string, a path
            binary_mode: bool, read as binary if True, otherwise text
            size: int, number of bytes or characters to read, otherwise
                read all the contents of the file from the offset
            offset: int, offset into file to read from, otherwise read
                from the very beginning

        Returns:
            Subset of the contents of the file as a string or bytes.
        """
        mode = "rb" if binary_mode else "r"
        with io.open(filename, mode) as f:
            if offset is not None:
                f.seek(offset)
            if size is not None:
                return f.read(size)
            else:
                return f.read()