Block on connect until handshake is done, Python 3 syntax, local imports

This fixes the problem that Firebase ref creation and send could happen during the handshake phase, which was causing some problems.  It's addressed by blocking until the handshake phase is done.

Also, some minor syntax changes for Python 3, and local import fixes.