Improve encode_film