fix encoding and footer