create encode methods for each formats