implement Writer and OutputStream interfaces