Recovery of hydrogen from impurities using a palladium membrane reactor