untested writeTLV code