Fix implementation for putchar

According to manual: putchar() return the character written as an
unsigned char cast to an int or EOF on error.

Use return value of write to return the correct value for putchar.