Formation of capsules