Patterning of the switching material