Crystal Palace have agreed a deal to sign goalkeeper Sam Johnstone on a free transfer when he leaves West Brom at the end of the month.