added support of output mode.  borrowed from the c# driver.