Fix bugs in x265