'Converts a markdown file and returns the HTML as a unicode string.
Decodes the file using the provided encoding (defaults to utf-8),
passes the file content to markdown, and outputs the html to either
the provided stream or the file with provided name, using the same
encoding as the source file.
**Note:** This is the only place that decoding and encoding of unicode
takes place in Python-Markdown.  (All other code is unicode-in /
unicode-out.)
Keyword arguments:
* input: Name of source text file.
* output: Name of output file. Writes to stdout if `None`.
* encoding: Encoding of input and output files. Defaults to utf-8.'

def convertFile(self, input=None, output=None, encoding=None):

    encoding = (encoding or 'utf-8')
    input_file = codecs.open(input, mode='r', encoding=encoding)
    text = input_file.read()
    input_file.close()
    text = text.lstrip(u'\ufeff')
    html = self.convert(text)
    if isinstance(output, (str, unicode)):
        output_file = codecs.open(output, 'w', encoding=encoding)
        output_file.write(html)
        output_file.close()
    else:
        output.write(html.encode(encoding))
