diff --git a/_scripts/sem2ical.py b/_scripts/sem2ical.py
index 1e9e4facdb9997963f7ab2c5334b75b48c8ec7a9..0387c4e54689dc0dcee93c1c2dceac8a67f841b4 100755
--- a/_scripts/sem2ical.py
+++ b/_scripts/sem2ical.py
@@ -1,5 +1,6 @@
 #!/usr/bin/python3
 # -*- coding: utf-8 -*-
+
 import yaml
 import locale
 from datetime import datetime, timedelta
@@ -31,7 +32,7 @@ calendar.add('x-wr-calname', 'Proofs and Algorithms seminar')
 f = open('../_data/seminar.yml')
 events = yaml.load_all(f, Loader=yaml.FullLoader)
 
-events = events.next()
+events = next(events)
 
 for data in events:
 
@@ -45,28 +46,28 @@ for data in events:
     
     # Compute fields
     team = data['team']
-    team = "?" if team == None else team.encode("utf-8")
+    team = "?" if team == None else team
     room = data['room']
     if not room.startswith("http"):
-        room = "room " + ("TBA" if room == None else room.encode("utf-8"))
+        room = "room " + ("TBA" if room == None else room)
     website = data['website']
-    website = "" if website == None else website.encode("utf-8")
-    speaker = data['speaker'].encode("utf-8")
+    website = "" if website == None else website
+    speaker = data['speaker']
     lab = data['lab']
-    lab = "" if lab == None else lab.encode("utf-8")
+    lab = "" if lab == None else lab
     picture = data['picture']
     picture = "http://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Anonymous.svg/433px-Anonymous.svg.png" if picture == None else picture
-    picture = "<a href=\"{website}\"><img src=\"{picture}\" class=\"picture\" alt=\"{speaker}\"/></a>".format(speaker=speaker,website=website,picture=picture.encode("utf-8"))
+    picture = "<a href=\"{website}\"><img src=\"{picture}\" class=\"picture\" alt=\"{speaker}\"/></a>".format(speaker=speaker,website=website,picture=picture)
     picturetweet = data['picture']
     picturetweet = "http://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Anonymous.svg/433px-Anonymous.svg.png" if picturetweet == None else picturetweet
-    # picturetweet = "<a href=\"{website}\"><img src=\"{picture}\" class=\"picture\" alt=\"{speaker}\"/></a>".format(speaker=speaker,website=website,picture=picture.encode("utf-8"))
+    # picturetweet = "<a href=\"{website}\"><img src=\"{picture}\" class=\"picture\" alt=\"{speaker}\"/></a>".format(speaker=speaker,website=website,picture=picture)
     date = dateutil.parser.parse(data['date'],dayfirst=False)
     date = tz.localize(date)
     datestring = date.strftime('%A %d %B %Y at %Hh%M')
     title = data['title']
-    title = "TBA" if title == None else title.encode("utf-8")
+    title = "TBA" if title == None else title
     abstract = data['abstract']
-    abstract = "TBA" if abstract == None else abstract.encode("utf-8")
+    abstract = "TBA" if abstract == None else abstract
 
     # Generate mail
     if date - datetime.now(tz) > timedelta():
@@ -163,6 +164,6 @@ for data in events:
 
 f.close()
 
-f = open("../seminar/calendar.ics", "w")
+f = open("../seminar/calendar.ics", "wb")
 f.write(calendar.to_ical())
 f.close()