def decode(self, inputfile, outputfile=None):
        byte_array = FileManager.load_bytes(inputfile)

        freq, code = FileManager.parse_bytes(byte_array, self.separator)
        decoded = self._decode(code, freq)

        if outputfile:
            FileManager.export(decoded, outputfile, "w")

        return decoded
    def encode(self, inputfile, outputfile=None):
        string = FileManager.load_text(inputfile) + \
                 self.break_symbol * (self.bits // 8)

        table = self.build_intervals(string)
        encoded = self._encode(string, table)

        if outputfile:
            data = FileManager.merge_data(table, self.separator, encoded)
            FileManager.export(data, outputfile, "wb")

        return encoded