Fixed an issue when encoding arrays