'write data into path.   If ensure is True create
missing parent directories.'

def write(self, data, mode='w', ensure=False):

    if ensure:
        self.dirpath().ensure(dir=1)
    if ('b' in mode):
        if (not py.builtin._isbytes(data)):
            raise ValueError('can    only    process    bytes')
    elif (not py.builtin._istext(data)):
        if (not py.builtin._isbytes(data)):
            data = str(data)
        else:
            data = py.builtin._totext(data, sys.getdefaultencoding())
    f = self.open(mode)
    try:
        f.write(data)
    finally:
        f.close()
