Spontaneous formation of knots in relativistic flows - A model for variability in compact synchrotron sources