Correctly return the number of bytes wrote in encoding conversion functions.