Crystal Palace sign midfielder Mathieu Flamini, who was a free agent after leaving Premier League rivals Arsenal this summer.