make serialization of complex arrays efficient. Resolves #40