Stabilization of ideal plasma resistive wall modes in cylindrical geometry: The effect of resistive layers