Reducing pure dephasing of quantum bits by collective encoding in quantum dot arrays