Optimizations for toBytesArray()/copyBytesArray() with tests for
sharing/non-sharing behaviour. Also added test for toBytes() that
verifies that it is cheap for small blocks (the common case).