Change arrayEncode/Decode to use DataRefs
Fix bug when writing binary data using "write" syntax