Model based clustering for three-way data structures