Add python3 support to server function, make it more cross-platform