Latvia will cooperate with neighbours Estonia, Lithuania, Poland and others to stop the flow of migrants.