refactored groups export

I have modified the groups export function to be able to export
large groups without getting a Server Error. This is to fix the
defect reported in Ticket #459.