Improve Python 3 compatibility when using daemon and client

Fixes #1008