function to write out labels
generate labels in grid form