If you check the type of object returned by this line:
html = g.response.body
you will see that it is not a unicode object:
print type(html)
...
<type 'str'>
so when you come to this line:
html = html.encode(enc, 'replace')
you are trying to re-encode a string that is already encoded (which causes the error).
To fix this, change your code to look like this:
# decode the dowloaded data
html = g.response.body.decode(enc)
# html is now a unicode object
html = html.replace('bgcolor="EDF389"', 'bgcolor="#EDF389"')
print html
# encode as utf-8 before writing to file (no need for 'replace')
html = html.encode(enc)