Add MAX_BYTES_WRITTEN

Better error handling via GetLastError(). Added maximal bound on written
bytes, see http://bugs.python.org/issue11395. Also, trying to write a
single byte raises an exception so infinite loop on buffer.flush() with
odd length is prevented.