Fix performance regression for writing Arrays to files