How imperfect drug penetration can lead to drug resistance