def fix(self, to_file=None):
self.packer_cmd = self.packer.fix<EOL>self._add_opt(self.packerfile)<EOL>result = self.packer_cmd()<EOL>if to_file:<EOL><INDENT>with open(to_file, '<STR_LIT:w>') as f:<EOL><INDENT>f.write(result.stdout.decode())<EOL><DEDENT><DEDENT>result.fixed = json.loads(result.stdout.decode())<EOL>return result<EOL>
Implements the `packer fix` function

        :param string to_file: File to output fixed template to