Supports UTF-8 value

Using `str(value)` breaks if the value is not ascii-encodable. This patch use `value.encode` instead to allow UTF-8 value to be encoded.