Fix termchar handling

Termination character is erroneously converted to a string, which
struct.pack cannot handle. This should be passed in as an integer.