Converting returned bytes object to string manually is causing it to be formatted as "b'contents'". If you tell lxml to return unicode, you get the proper "contents".