Write mock config correctly when run in Py 3
Mock config is a plain text file, so it is unnecessary to write in
binary mode. When run in Python 3, original code fails due to it writes
a unicode string in binary mode without encode in advance.
Tests are updated accordingly. Now, file operations like open and write
are not mocked, which can catch any potential issues happening during
those calls.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>