Update encode.lua

Added separation function.