copy to unsigned char buffer