openpic: move gcr write into a function